<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
//数组解构赋值
        let arr=[11,22,33,44];
        // let a=arr[0];
        // let b=arr[1];

        let [a,b,...c] =[11,22,33,44]; // 数组：有序的集合
        console.log(a,b,c)

        let [[d,e],[f,[g],[h]]]=[ [11,22],[33,[44],[55]] ]
        console.log(d,e,f,g,h)

//对象解构赋值
        let obj={ "name":"gao","age":18 };
        // let name =obj.name;
        // let age =obj.age;

        // :别名  =默认值
        let {name:n,age,sex='男'}={ "name":"gao","age":18 } // 对象：无序的属性集合
        console.log(n,age,sex)

//交换变量值
        let x=1;    // 2
        let y=2;    // 1

/*
        let z;
        z=x;
        x=y;
        y=z;
        console.log(x,y)
*/

// 冒泡排序。。。？？？
        [y,x] = [x,y]
        console.log(x,y)






    </script>
</body>
</html>